package com.ruicar.afs.cloud.product.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @author yaorui.zhang
 * @date 2020年5月11日19:20:57
 */
@Data
@TableName("product_plan")
@ApiModel(value = "产品投放方案表")
@NoArgsConstructor
public class ProductPlan extends BaseEntity<ProductPlan> {

    @ApiModelProperty(value = "产品模板ID")
    @JsonSerialize(using = ToStringSerializer.class)
    @NotBlank(message = "产品模板ID不能为空")
    private Long productTemplateId;

    @ApiModelProperty(value = "模板类别;主产品、子产品")
    private String templateCategory;

    @ApiModelProperty(value = "是否原型;0-否；1-是")
    private String isModel;

    @ApiModelProperty(value = "产品原型ID")
    @JsonSerialize(using = ToStringSerializer.class)
    @NotBlank(message = "产品原型ID不能为空")
    private Long productPrototypeId;

    @ApiModelProperty(value = "状态;0-未生效；1-生效；2-上线；3-弃用")
    private String status;

    @ApiModelProperty(value = "状态;0-未修改；1-修改中")
    private String updateFlag;

    @ApiModelProperty(value = "版本号")
    private Integer versionNumber;

    @ApiModelProperty(value = "产品类别")
    private String productCategory;

    @ApiModelProperty(value = "产品分组")
    private String productGrouping;

    @ApiModelProperty(value = "产品编号")
    private String productNumber;

    @ApiModelProperty(value = "产品名称")
    private String productName;

    @ApiModelProperty(value = "开始时间 ")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    @ApiModelProperty(value = "结束时间 ")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    @ApiModelProperty(value = "产品描述 ")
    private String productDescribe;

    @ApiModelProperty(value = "贴息方案编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private String discountPlanId;

    @ApiModelProperty(value = "贴息方案名称")
    private String discountPlanName;

    @ApiModelProperty(value = "附加贷方案编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private String extrasPlanId;

    @ApiModelProperty(value = "附加贷方案名称")
    private String extrasPlanName;

    @ApiModelProperty(value = "产品投放方案编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private String launchPlanId;

    @ApiModelProperty(value = "产品投放方案名称")
    private String launchPlanName;

    @ApiModelProperty(value = "风险定价方案编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private String riskPlanId;

    @ApiModelProperty(value = "风险定价方案名称")
    private String riskPlanName;

    @ApiModelProperty(value = "融资校验方案编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private String financePlanId;

    @ApiModelProperty(value = "融资校验方案名称")
    private String financePlanName;

    public ProductPlan(ProductPlan plan) {
        plan.setId(null);
        plan.setCreateBy(null);
        plan.setCreateTime(null);
        plan.setUpdateBy(null);
        plan.setUpdateTime(null);
        plan.setVersionNumber(1);
        BeanUtils.copyProperties(plan, this);
    }
}
